//修改发票信息
//获得发票信息===修改===页面
function get_update_invoice_info(){
	$("#changeInvoiceInfo").css("display", "none");
	
	$.ajax({
		type : "post",
		dataType: "html",
		url : "../invoice/invoice_edit",
		async: true,
		data:{
			receiverId:$("#invoice_detail input[name=receiverId]").val(),
			bizZhyCode:$("#saveInvoiceReceiver input[name=bizZhyCode]").val()
		},
		success : function(data) {
			$("#invoice_info_jsp").empty().html(data);
		}
	});
}

//修改发票信息
function update_invoice_info(){
	if(!$("#invoiceEditForm").validationEngine("validate")){
		return false;
	} 
	
	// 开具类型
	var openTypeValue = $("#editInvoiceInfo button[name=openTypeMenu]").attr("value")
	if (openTypeValue=="" || openTypeValue=="0"){
		$("#invoiceEditForm #openTypeError").css("display", "inline-block")
		return false;
	}else {
		$("#invoiceEditForm #openTypeError").css("display", "none")
	}
	
	// 图片
	var businessLicenseImg = $("#invoiceEditForm #businessLicenseImg").attr("src");
	if (businessLicenseImg=="" || businessLicenseImg==null){
		$("#invoiceEditForm #businessLicenseError").css("display", "inline-block")
		return false;
	}else {
		$("#invoiceEditForm #businessLicenseError").css("display", "none")
	}

	var taxQuaAuthImg = $("#invoiceEditForm #taxQuaAuthImg").attr("src");
	if (taxQuaAuthImg=="" || taxQuaAuthImg==null){
		$("#invoiceEditForm #taxQuaAuthError").css("display", "inline-block")
		return false;
	}else {
		$("#invoiceEditForm #taxQuaAuthError").css("display", "none")
	}

	var taxRegisterImg = $("#invoiceEditForm #taxRegisterImg").attr("src");
	if (taxRegisterImg=="" || taxRegisterImg==null){
		$("#invoiceEditForm #taxRegisterError").css("display", "inline-block")
		return false;
	}else{
		$("#invoiceEditForm #taxRegisterError").css("display", "none")
	}
	
	$.ajax({
		type : "post",
		dataType: "json",
		url : "../invoice/invoice_update",
		async: false,
		data:{
			bizZhyCode:$("#saveInvoiceReceiver input[name=bizZhyCode]").val(),
			receiverId:$("#editInvoiceInfo input[name=receiverId]").val(),
			invoiceHead:$("#editInvoiceInfo input[name=invoiceHead]").val(),
			
			openType:$("#editInvoiceInfo button[name=openTypeMenu]").attr("value"),
			invoiceType:$("#editInvoiceInfo button[name=invoiceTypeMenu]").attr("value"),
			
			taxRegisterCode:$("#editInvoiceInfo input[name=taxRegisterCode]").val(),
			bankName:$("#editInvoiceInfo input[name=bankName]").val(),
			bankCode:$("#editInvoiceInfo input[name=bankCode]").val(),
			phone:$("#editInvoiceInfo input[name=phone]").val(),
			
			province:$("#editInvoiceInfo input[name=province]").val(),
			provinceName:$("#editInvoiceInfo div[name=province] button.dropdown-text").text(),
			city:$("#editInvoiceInfo input[name=city]").val(),
			cityName:$("#editInvoiceInfo div[name=city] button.dropdown-text").text(),
			area:$("#editInvoiceInfo input[name=area]").val(),
			areaName:$("#editInvoiceInfo div[name=area] button.dropdown-text").text(),
			address:$("#editInvoiceInfo input[name=invoiceAddress]").val(),
			
			businessLicense:$("#editInvoiceInfo input[name=businessLicense]").val(),
			taxQuaAuth:$("#editInvoiceInfo input[name=taxQuaAuth]").val(),
			taxRegister:$("#editInvoiceInfo input[name=taxRegister]").val()
		},
		success : function(data) {
			if(data.result){
				get_see_invoice_info();
			}else{
				zhyAlert(data.message);
			}
		}
	});
}

//获得发票信息===查看===页面
function get_see_invoice_info(){
	$("#changeInvoiceInfo").css("display", "block");
	
	$.ajax({
		type : "post",
		dataType: "html",
		url : "../invoice/invoice_info",
		async: true,
		data:{
			receiverId:$("#editInvoiceInfo input[name=receiverId]").val()
		},
		success : function(data) {
			$("#invoice_info_jsp").empty().html(data);
		}
	});
}
